package com.intct.hbase.ddl.namespace;

import com.intct.hbase.util.HBaseConnection;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;

import java.io.IOException;

/**
 * @author gufg
 * @since 2025-07-10 11:30
 */
public abstract class AbsNamespace {
    /**
     * 抽象类中实现方法，把需要执行的步骤写出来
     * @throws IOException
     */
    public void start() throws IOException {
        // 连接HBase
        Connection connection = HBaseConnection.getConnection();

        // 创建Admin实例
        Admin admin = connection.getAdmin();

        try {
            execCommand(admin);
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭资源
            admin.close();
        }
    }
    public abstract void execCommand(Admin admin) throws IOException ;
}
